package everyday;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/6/14 21:20
 * 1732. 找到最高海拔
 * https://leetcode.cn/problems/find-the-highest-altitude/
 */
public class Solution1732 {

    public int largestAltitude(int[] gain) {
        int n = gain.length;
        int[] height = new int[n + 1];  // height[1] 表示 1 位置的海拔
        int maxHeight = 0;
        for (int i = 1; i <= n; ++i) {
            height[i] = gain[i - 1] + height[i - 1];
            maxHeight = Math.max(maxHeight, height[i]);
        }
        return maxHeight;
    }
}
